package com.companyName.sample.service.impl.sys;

import com.companyName.sample.api.service.sys.OrganizationService;
import com.companyName.sample.bean.dto.sys.Tree;
import com.companyName.sample.common.util.CommUtil;
import com.companyName.sample.data.entity.OrganizationPo;
import com.companyName.sample.data.mapper.OrganizationMapper;
import com.companyName.sample.service.business.OrganizationBiz;
import com.google.common.collect.Lists;
import com.companyName.sample.bean.dto.sys.OrganizationDto;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class OrganizationServiceImpl implements OrganizationService {

    private static final Logger logger = LoggerFactory.getLogger(LogServiceImpl.class);

    @Autowired
    private OrganizationBiz organizationBiz;

    @Override
    public List<Tree> findTree() {
        return organizationBiz.findTree();
    }

    @Override
    public List<OrganizationDto> findTreeGrid() {
        return organizationBiz.findTreeGrid();
    }

    @Override
    public void addOrganization(OrganizationDto organizationDto) {
        OrganizationPo organizationPo = new OrganizationPo();
        CommUtil.copyProperties(organizationDto, organizationPo);
        organizationBiz.addOrganization(organizationPo);
    }

    @Override
    public OrganizationDto findOrganizationById(Long id) {
        return organizationBiz.findOrganizationById(id);
    }

    @Override
    public void updateOrganization(OrganizationDto organizationDto) {
        OrganizationPo organizationPo = new OrganizationPo();
        CommUtil.copyProperties(organizationDto, organizationPo);
        organizationBiz.updateOrganization(organizationPo);
    }

    @Override
    public void deleteOrganizationById(Long id) {
        organizationBiz.deleteOrganizationById(id);
    }

}
